﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UtilReport
{
    public partial class frmCanhLe : Form
    {
        CanLe _canle = new CanLe();

        public frmCanhLe(CanLe c)
        {            
            InitializeComponent();
            _canle = c;
            this.Load += new EventHandler(frmCanhLe_Load);         
        }

        void frmCanhLe_Load(object sender, EventArgs e)
        {
            txtBottom.Text = _canle.Bottom.ToString();
            txtLeft.Text = _canle.Left.ToString();
            txtRight.Text = _canle.Right.ToString();
            txtTop.Text = _canle.Top.ToString();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                _canle.Bottom = int.Parse(txtBottom.Text);
                _canle.Left = int.Parse(txtLeft.Text);
                _canle.Top=int.Parse(txtTop.Text);
                _canle.Right=int.Parse(txtRight.Text);
                this.DialogResult = DialogResult.Yes;
                this.Hide();
            }catch(Exception ex){
                lblstatus.Text="Dữ liệu nhập vào sai: "+ ex.Message;
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Hide();
        }
        
    }
    public class CanLe
    {
        public int Left=0;
        public int Right=0;
        public int Top=0;
        public int Bottom=0;

        public void setInforToReport(ref CrystalDecisions.Shared.PageMargins margins)
        {
            margins.bottomMargin = Bottom;
            margins.leftMargin = Left;
            margins.rightMargin = Right;
            margins.topMargin = Top;
        }

        public void getInforToReport(CrystalDecisions.Shared.PageMargins margins)
        {
            Bottom = margins.bottomMargin;
            Left = margins.leftMargin;
            Right = margins.rightMargin;
            Top = margins.topMargin;
        }
    }
}
